import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:untitled1/app/broker/modules/serve/serve_page/ServerListView.dart';
import 'package:untitled1/app/res/myColors.dart';
import 'package:untitled1/app/utils/utilRouter.dart';
import 'package:untitled1/app/utils/utilScreen.dart';
import 'package:untitled1/app/widgets/toast/MyToast.dart';
import '../../../widgets/base_page/BaseStatefulPage.dart';
import '../employer/EmployerPageController.dart';
import '../employer/employer_page/employer_page_dialog/EmployerPageDialog.dart';
import 'ServePageController.dart';
//服务人列表
class ServePage extends BaseStatefulPage {
  const ServePage({super.key}) : super(pageName: "首页");

  @override
  BaseStatefulPageState<BaseStatefulPage> createState() => _ServePeoplePageState();
}

class _ServePeoplePageState extends BaseStatefulPageState<ServePage> {
  String? _error;
  bool _isEmpty = false;
  final ServerPeoplePageController controller = Get.put(ServerPeoplePageController());


  @override
  Widget buildPage(BuildContext context) {
    if (_error != null) {
      return buildErrorView(_error);
    }
    if (_isEmpty) {
      return buildEmptyView();
    }

    return Scaffold(
      body: Obx(() =>Container(
        color: myColors.white,
        width: utilScreen.getScreenWidth(context),
        height: utilScreen.getScreenHeight(context),
        child: Column(
          children: [
            SizedBox(height: 50, width: double.infinity),
            Container(
              height: 50,
              width: double.infinity,
              child: Stack(
                children: [
                  Align(
                    alignment: Alignment.centerLeft,
                    child:  Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Container(
                          alignment: Alignment(-2, 0),
                          child: TextButton(
                            onPressed: () {
                              controller.page_index.value = 0;
                            },
                            child: (Text("全部", style: getViewSelectTitle(0))),
                          ),
                        ),
                        Container(
                          alignment: Alignment(-2, 0),
                          child: TextButton(
                            onPressed: () {
                              controller.page_index.value = 1;
                            },
                            child: Text("我锁定", style: getViewSelectTitle(1)),
                          ),
                        ),
                      ],
                    ),

                  ),
                  Align(
                    alignment: Alignment.centerRight,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        GestureDetector(
                          onTap: () {
                            print('按钮被点击了');
                            MyToast.show(context,'aaa');
                            EmployerPageDialog.dialog_workTypeSelect(context,(data){
                              print(">]拿到数据 data1=${data['list_gz']?.length}");
                              print(">]拿到数据 data2=${data['list_xz']?.length}");
                            });

                          },
                          child:    Container(
                            child: Image.asset(
                              "assets/app/home_px1.png",
                              height: 25,
                              width: 25,
                            ),
                          ),
                        ),
                        SizedBox(width: 10),
                        GestureDetector(
                          onTap: () {
                            print('按钮被点击了');
                            MyToast.show(context,'aaa');
                            EmployerPageDialog.dialog_citySelect(context,(data){

                            });


                          },
                          child: Container(
                            child: Image.asset(
                              "assets/app/home_sx.png",
                              height: 25,
                              width: 25,
                            ),
                          ),
                        ),
                        SizedBox(width: 10)
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Divider(height: 2, thickness: 1,color: myColors.c_D1D3D5),
            Expanded(
                child: IndexedStack(
                  index: controller.page_index.value,
                  sizing: StackFit.expand,

                  children: [
                    ServeListView(type: 0,page_index:  controller.page_index.value),
                    ServeListView(type: 1,page_index:  controller.page_index.value),
                    // getListView(context,1),
                    // getListView(context,2)
                  ],
                )

            ),
          ],
        ),
      )),
    );
  }

  TextStyle getViewSelectTitle(int index) {
    if (index == controller.page_index.value) {
      return TextStyle(
        color: myColors.c_191919,
        fontSize: 20,
        fontWeight: FontWeight.bold,
      );
    }
    return TextStyle(
      color: myColors.c_191919,
      fontSize: 16,
      fontWeight: FontWeight.normal,
    );
  }
  Widget getView(int type){
    return Text("type${type}");
  }

}
